<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta name="author" content="wangyupeng">
		<title>帐户冻结解冻</title>
		<script language="javascript" src="../script/common.js"  type="text/javascript"></script>
		<script type="text/javascript" language="JavaScript" src="../script/tree.js"></script>
		
		<!--动态js-->
		<script type="text/javascript">
			//全局变量
			var org = Common.cOrg();	//当前单位	
			var qt = null;	
			var cardUserType;			//冻结、解冻的客户类型
			var cardUserStatus;			//客户状态
		//页面控件初始化
			function load(){
				cardUserType = getPara("cardUserType");
				cardUserStatus = getPara("cardUserStatus");
				setPages(["listview","carduserview"]);//切换页面
				var items = Common.getSubsetItems(CardStatus.CATEGORY,[cardUserStatus]);
				Common.initDict(searchForm.cardUserStatus,items);
				if (cardUserType == CardUserType.COMPANY)
					searchForm.isCompany.value = "company";
				else
					searchForm.isNameDriver.value = "nameordriver";
				var cOrg = Common.cOrg()

				searchForm.currentOrg.value = cOrg.id;
				searchForm.currentOrgLevel.value = cOrg.orgLevel;
				createTable();	 
			}
			//单位客户列表
			function createTable(){
				var columns = []						
				columns[0] = {type:"checkbox"}
				columns[1] = {render:nameFunc}
				var buttons = []
				if (cardUserStatus == CardUserStatus.OK){
					buttons = [{value:"冻 结",actions:lock}]
				}else{
					buttons = [{value:"解 冻",actions:unlock}]
				}
				qt = new QueryTable("carduser_lock","searchForm","datalist",columns,{
					buttons:buttons
				});
			}
			
			//冻结帐户
			function lock(){	
				var ids = qt.getBoxValue();
				if (!ids){
					showWarning("请选择帐户！");
					return;
				}
				
				if (!showQuestion("是否冻结这些帐户？")) return;
				
				openDialogFrame("/card/input_reason.html","请输入冻结原因",160,280,function(description){
					DWR.call("customerService.lockCardUser",ids,description,function(){
						showInformation("帐户冻结成功");
						showData();
					},{disCtrl:$("lockBtn")});
				}); 
			}
			//解冻帐户
			function unlock(){	
				var ids = qt.getBoxValue();
				if (!ids){
					showWarning("请选择帐户！");
					return;
				}
				if (showQuestion("是否解冻这些帐户？"))
					DWR.call("customerService.unlockCardUser",ids,function(){
						showInformation("帐户解冻成功");
						showData();
					},{disCtrl:$("unlockBtn")});
			}
			//处理数据 点姓名进入明细页面
			function nameFunc(v,r){
				return "<a href=# onclick=\"onShow("+r[0]+");return false;\">"+v+"</a>"
			}
			//刷新页面
			function showData(){	
				qt.showTable();				//qt为全局的QueryTable对象
			}
			//编辑页面
			function onShow(id){			//编辑页面
				var opts = {isView:true}
				switchPage("carduserview");
				CardMgnt.userDetail.show("carduserview",id,null,opts)
			}
			function onCancel(){
				switchPage("listview");
				searchForm.reset();
				if (cardUserType == CardUserType.COMPANY)
					searchForm.isCompany.value = "company";
				else
					searchForm.isNameDriver.value = "nameordriver";
				var cOrg = Common.cOrg()
				searchForm.currentOrg.value = cOrg.id;
				searchForm.currentOrgLevel.value = cOrg.orgLevel;
			}
		</script>
	</head>
	<body onload="load()">
		<!--页面导航-->
		<!--查询静态页面部分-->
		<div id="listview">	
			<!--查询条件form-->
			<form id="searchForm" name="searchForm">
				<input type="hidden" name="currentOrg">
				<input type="hidden" name="currentOrgLevel">
				<input type="hidden" name="isNameDriver">
				<input type="hidden" name="isCompany">
				<div class="searchForm">
					<table cellSpacing="0" cellPadding="4" width="100%" border="0">
						<tr>
							<td><label>客户名称</label> <input type=text name="name"></td>
							<td><label>客户编号</label> <input type=text name="uniqueId" onBlur="checkV(this,'uniqueId')"></td>
							<td><label>状&nbsp;&nbsp;&nbsp;&nbsp;态</label> <select name="cardUserStatus"><option></option></select></td>
							<td><button type="button" onclick="showData()">查 询</button></td>
						</tr>
					</table>
				</div>
			</form>
			<!--查询结构列表-->
				<div id="datalist"></div>
		</div>
		<!--明细静态显示部分-->
		<div id="carduserview" style="display:none;">
		</div>
	</body>
</html>